package week07.data_obs2;

import java.util.Observable;

/**
 * Created by zhangxiaokun on 2018/3/13.
 */
public class NumsObservable extends Observable {
    public final static Integer ODD = 1;    //奇数
    public final static Integer EVEN = 2;   //偶数
    private int data = 0;

    public int getData() {
        return data;
    }

    public void setData(int i) {
           data = i;
           Integer flag = EVEN; //偶数
           if ( (data % 2) == 1) {
               flag = ODD;
           }
           setChanged();
           notifyObservers(flag);
    }


}
